package com.oig.sys.feign.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
@ConfigurationProperties(prefix = "feign.customize")
public class FeignProperties implements InitializingBean  {

    private List<String> ignoreHeadCopyClients = new ArrayList<>();

    public List<String> getIgnoreHeadCopyClients() {
        return ignoreHeadCopyClients;
    }

    public void setIgnoreHeadCopyClients(List<String> ignoreHeadCopyClients) {
        this.ignoreHeadCopyClients = ignoreHeadCopyClients;
    }

    @Override
    public void afterPropertiesSet() {
        log.info("ignore feign names:{}", ignoreHeadCopyClients);
        ignoreHeadCopyClients.addAll(Stream.of("YiPiaoYun", "sys-oauth-security").collect(Collectors.toList()));
        log.info("add default ignore feign names:{}", ignoreHeadCopyClients);
    }
}
